package com.jinke.api.generator;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

import java.util.HashMap;
import java.util.Map;
public class GsonUtil {
    public static Map<String, String> convertJsonStringToHashMap(String jsonString) {
        Gson gson = new Gson();
        JsonArray jsonArray = gson.fromJson(jsonString, JsonArray.class);
        Map<String, String> result = new HashMap<>();
        for (JsonElement element : jsonArray) {
            JsonObject jsonObject = element.getAsJsonObject();
            String key = jsonObject.get("key").getAsString();
            String value = jsonObject.get("value").getAsString();
            result.put(key, value);
        }
        return result;
    }
}
